package br.usp.ime.ingpos.modelo.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.RequestScoped;
import br.com.caelum.vraptor.util.hibernate.SessionCreator;
import br.usp.ime.ingpos.modelo.DisciplinaEspecial;

@Component
@RequestScoped
public class DisciplinaEspecialDAO
    extends
        AbstractDaoImpl<Long,DisciplinaEspecial>
{

    public DisciplinaEspecialDAO(
        SessionCreator sessionCreator )
    {
        super( sessionCreator );
        // TODO Auto-generated constructor stub
    }

    public void adicionarDisciplinaEspecial(
        DisciplinaEspecial disciplinaEspecial )
    {
        save( disciplinaEspecial );
    }

    public DisciplinaEspecial procurarDisciplinaEspecialPorID(
        Long disciplinaEspecialID )
    {
        List<DisciplinaEspecial> listaDeDisciplinas = findByCriteria( Restrictions.eq(
            "disciplinaEspecialID", disciplinaEspecialID ) );
        if( listaDeDisciplinas.isEmpty() )
            return null;
        else {
            return listaDeDisciplinas.get( 0 );
        }
    }

    public List<DisciplinaEspecial> procurarTodasDisciplinasEspeciais()
    {
        return findAll();
    }

    public void deletarDisciplinaEspecial(
        DisciplinaEspecial disciplinaEspecial )
    {
        delete( disciplinaEspecial );
    }
}
